<?php


	
		#$connection = ssh2_connect('91.212.254.15', 22);
		#ssh2_auth_password($connection, 'lucian', 'Plucian');

				$connection = ssh2_connect('91.212.254.9', 22);
									ssh2_auth_password($connection, 'sysop', 'sysop');
		
	#$sftp = ssh2_sftp($connection);
	
	
	
	
	
	
	
	
	
		
		
	#$stream = ssh2_exec($connection, "echo '2014-05-28 10:00;2014-05-28 10:30;RO.CVD1.*.*' > stream.lst; echo '__COMMAND_FINISHED__'");
	#$stream = ssh2_exec($connection, "seiscomp exec scart -ds --list stream.lst /home/sysop/seiscomp3/var/lib/archive > sorted.mseed; echo '__COMMAND_FINISHED__'");

	
	
	// COMANDA ARC LINK 
	#$stream = ssh2_exec($connection, "echo '2014,05,28,10,00,00 2014,05,28,10,20,00 RO ARR *' > lucianR.txt; echo '__COMMAND_FINISHED__'");
	#$stream = ssh2_exec($connection, "seiscomp exec arclink_fetch -t 3600 -u sysop -o lucian_arc2.mseed lucianR.txt; echo '__COMMAND_FINISHED__'");
	// COMANDA ARC LINK 
	
	
	// comanda copiat fisier seed in descarcari
	//ssh2_scp_recv($connection, '/home/sysop/stream_luciand.lst', 'stream.lst');
	// comanda copiat fisier seed in descarcari
	
	
	/*
	$arr = array();
	for($i=0;$i<=10;$i++){
		$arr[] = "linia: ".$i;
	}
	

	$stream = ssh2_exec($connection, "echo". implode("\n",$arr)."' > stream_luciand.lst; echo '__COMMAND_FINISHED__'");
	*/
	
	$dataEveniment = "2014-06-10 16:54:20";
	if(date("z",strtotime($dataEveniment) + 86400 ) < 100){
		$fisier = date("Y0z_H_i_s", strtotime($dataEveniment) + (86400 - 10800) );
		}else{
		$fisier = date("Yz_H_i_s", strtotime($dataEveniment) + (86400 - 10800) );
		}
	
	
	#$stream = ssh2_exec($connection, "ls '/home/rt/bulletins_ronet/manual/reb/sent_by_email'; echo '__COMMAND_FINISHED__'");
	#$stream = ssh2_exec($connection, "ls '/home/sysop/'; echo '__COMMAND_FINISHED__'");
	
	$stream = ssh2_scp_recv($connection, '/home/sysop/2014-06-11_11-06__dj_brom@yahoo.com_.lst', 'descarcari/sss.lst');
	

	/*
	stream_set_blocking($stream, true);
	 $data = '';
    while($buffer = fread($stream, 4096)) {
      $data .= $buffer;
    }
		fclose($stream);
		
	echo $data;
	echo $fisier;
	*/
	/*
	if (strpos($data,"__COMMAND_FINISHED__") !== false) {
		echo "<br/><br/><b>COMANDA TERMINATA ARCH</b>";
	}
	*/

	


	#echo "Output: " . stream_get_line($stream);
	#echo "Error: " . stream_get_contents($errorStream);
	#
	

	
	

	

	
	
	
	
	
	
	
	/*
	$stream = ssh2_exec($connection, "ls ; echo '__COMMAND_FINISHED__'");

	
	stream_set_blocking($stream, true);
	 $data = '';
    while($buffer = fread($stream, 4096)) {
      $data .= $buffer;
    }
		fclose($stream);
		
	echo $data;
		
	if (strpos($data,"__COMMAND_FINISHED__") !== false) {
		echo "<br/><br/><b>COMANDA TERMINATA ARCH</b>";
	}
	
	*/
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
?>

